package com.example.yuejian.yuejian.bean;

import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Administrator on 2017/9/13.
 */

public class Login {

    /**
     * retCode : 1
     * retMsg : 登陆成功
     * data : {"id":2,"password":"123","nickname":"戴仁k","turename":"12","phone":"18910789115","gender":0,"photo":"2017-09-01-07-05-26-59a906b68b5b5.jpg","address":"dalian","club_id":1}
     */

    private int retCode;
    private String retMsg;
    private DataEntity data;

    public static Login objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), Login.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public void setRetCode(int retCode) {
        this.retCode = retCode;
    }

    public void setRetMsg(String retMsg) {
        this.retMsg = retMsg;
    }

    public void setData(DataEntity data) {
        this.data = data;
    }

    public int getRetCode() {
        return retCode;
    }

    public String getRetMsg() {
        return retMsg;
    }

    public DataEntity getData() {
        return data;
    }

    public static class DataEntity {
        /**
         * id : 2
         * password : 123
         * nickname : 戴仁k
         * turename : 12
         * phone : 18910789115
         * gender : 0
         * photo : 2017-09-01-07-05-26-59a906b68b5b5.jpg
         * address : dalian
         * club_id : 1
         */

        private int id;
        private String password;
        private String nickname;
        private String turename;
        private String phone;
        private int gender;
        private String photo;
        private String address;
        private int club_id;

        public static DataEntity objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataEntity.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public void setId(int id) {
            this.id = id;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public void setNickname(String nickname) {
            this.nickname = nickname;
        }

        public void setTurename(String turename) {
            this.turename = turename;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }

        public void setGender(int gender) {
            this.gender = gender;
        }

        public void setPhoto(String photo) {
            this.photo = photo;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public void setClub_id(int club_id) {
            this.club_id = club_id;
        }

        public int getId() {
            return id;
        }

        public String getPassword() {
            return password;
        }

        public String getNickname() {
            return nickname;
        }

        public String getTurename() {
            return turename;
        }

        public String getPhone() {
            return phone;
        }

        public int getGender() {
            return gender;
        }

        public String getPhoto() {
            return photo;
        }

        public String getAddress() {
            return address;
        }

        public int getClub_id() {
            return club_id;
        }
    }
}
